Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sourcery Starbot ⭐ refactored enthyp/chat #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/chat master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Comment on lines -88 to +89
else:
log.err('DB: password_correct CALL FAILURE: no such user in database')
raise failure.Failure(sqlite3.IntegrityError())
log.err('DB: password_correct CALL FAILURE: no such user in database')
raise failure.Failure(sqlite3.IntegrityError())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DBService.password_correct refactored with the following changes:

  • Remove unnecessary else after guard condition (remove-unnecessary-else)

Comment on lines -177 to +176
results = yield self._dbpool.runQuery(query.select_notifications, (user,))
return results
return (yield self._dbpool.runQuery(query.select_notifications, (user,)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DBService.get_notifications refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

nicks = []
for k, v in self.user2peer.items():
if v == peer:
nicks.append(k)
nicks = [k for k, v in self.user2peer.items() if v == peer]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Dispatcher.remove_peer refactored with the following changes:

  • Convert for loop into list comprehension (list-comprehension)

@@ -490,7 +490,6 @@ def msg_JOIN(self, message):
else:
if self.connected:
self.endpoint.no_channel(channel_name)
pass
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function LoggedInState.msg_JOIN refactored with the following changes:

  • Remove redundant pass statement (remove-redundant-pass)

Comment on lines -97 to +98
if message.strip(" ") != "":
if self.client:
self.client.handle_input(message.strip(" "))
if message.strip(" ") != "" and self.client:
self.client.handle_input(message.strip(" "))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function GUI.send_message refactored with the following changes:

  • Merge nested if conditions (merge-nested-ifs)

conn = sqlite3.connect(app.config['DATABASE'])
return conn
return sqlite3.connect(app.config['DATABASE'])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function connect_db refactored with the following changes:

  • Inline variable that is immediately returned (inline-immediately-returned-variable)

return list(set([row[1] for row in rows]))
return list({row[1] for row in rows})
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function extract_channels refactored with the following changes:

  • Replace unneeded comprehension with generator (comprehension-to-generator)
  • Replace list(), dict() or set() with comprehension (collection-builtin-to-comprehension)

Comment on lines -72 to +73
for i in range(0, len(ratings_list)):
for j in range(0, 6):
for i in range(len(ratings_list)):
for j in range(6):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function history refactored with the following changes:

  • Replace range(0, x) with range(x) (remove-zero-from-range)

Comment on lines -98 to +99
for i in range(0, len(ratings_list)):
for j in range(0, 6):
for i in range(len(ratings_list)):
for j in range(6):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function channel refactored with the following changes:

  • Replace range(0, x) with range(x) (remove-zero-from-range)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant